import 'package:enterprise_v6_app/app/components/organize_tree/emergency_department_tree.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/ext.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/emergency_plan/common/emergency_plan_common_widget.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/emergency_plan/emergency_plan_details/plan_information/plan_information_controller.dart';

/// 预案信息页面
class PlanInformationPage extends StatelessWidget {
  PlanInformationPage({super.key});

  final controller = Get.put(PlanInformationController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Obx(() {
            return Column(
              children: [
                // 切换按钮
                _getSwitchView(),
                Divider(height: 1.w, color: AppColors.bg_color_grey),
                // 内容显示
                Expanded(
                    child: controller.index.value == 1
                        ? EmergencyPlanCommonWidget.getBasicInformationWidget(controller.entity)
                        : EmergencyDepartmentTree(businessId: controller.entity.id))
              ],
            );
          });
        });
  }

  /// 切换按钮
  Widget _getSwitchView() {
    return Container(
      alignment: Alignment.center,
      color: const Color(0xffffffff),
      padding: EdgeInsets.symmetric(vertical: 12.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
            alignment: Alignment.center,
            width: 100.w,
            padding: EdgeInsets.symmetric(vertical: 7.w),
            decoration: BoxDecoration(
              color: controller.index.value == 1 ? const Color(0xff5C6DFF) : const Color(0xffECEFF5),
              borderRadius: BorderRadius.circular(4.r),
            ),
            child: Text(
              '基本信息',
              style: TextStyle(
                fontSize: 14.sp,
                height: 1.2,
                fontWeight: FontWeight.w400,
                color: controller.index.value == 1 ? const Color(0xffffffff) : const Color(0xff9FA5B0),
              ),
            ),
          ).clickOnce(() {
            controller.onChangeIndex(1);
          }),
          AppGaps.hGap10,
          Container(
            alignment: Alignment.center,
            width: 100.w,
            padding: EdgeInsets.symmetric(vertical: 7.w),
            decoration: BoxDecoration(
              color: controller.index.value != 1 ? const Color(0xff5C6DFF) : const Color(0xffECEFF5),
              borderRadius: BorderRadius.circular(4.r),
            ),
            child: Text(
              '应急组织人员',
              style: TextStyle(
                fontSize: 14.sp,
                height: 1.2,
                fontWeight: FontWeight.w400,
                color: controller.index.value != 1 ? const Color(0xffffffff) : const Color(0xff9FA5B0),
              ),
            ),
          ).clickOnce(() {
            controller.onChangeIndex(2);
          }),
        ],
      ),
    );
  }
}
